package kz.edu.sdu.itech.pcs.server;

import java.io.IOException;
import java.net.Socket;

import org.apache.log4j.Logger;

public class MonitorListener extends Thread implements Runnable {

   public static final int SLEEP = 1000;

   static Logger log = Logger.getLogger(MonitorListener.class);

   Server server;

   public MonitorListener() {

   }

   public MonitorListener(Server server) {
      this.server = server;
   }

   @Override
   public void run() {
      log.info("Listen for monitor connections");
      while (!AppProps.DONE) {
         try {
            Socket clientSocket = server.monitorSocket.accept();
            Monitor monitor = new Monitor(clientSocket, server);
            log.debug("monitor came in");
//            server.workerSet.add(worker);
            monitor.start();
         } catch (IOException e) {
//               e.printStackTrace();
         }
      }
   }

   public void sleep(int x) {
      try {
         Thread.sleep(x);
      } catch (Exception e) {

      }
   }

}
